package com.ruoyi.web.controller.modules;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.modules.domain.CertificateBlack;
import com.ruoyi.modules.service.ICertificateBlackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业信用名单Controller
 * 
 * @author ssh
 * @date 2024-12-15
 */
@RestController
@RequestMapping("/modules/certificate/black")
public class CertificateBlackController extends BaseController
{
    @Autowired
    private ICertificateBlackService certificateBlackService;

    /**
     * 查询企业信用名单列表
     */
    @PreAuthorize("@ss.hasPermi('modules:black:list')")
    @GetMapping("/list")
    public TableDataInfo list(CertificateBlack certificateBlack)
    {
        startPage();
        List<CertificateBlack> list = certificateBlackService.selectCertificateBlackList(certificateBlack);
        return getDataTable(list);
    }

    /**
     * 导出企业信用名单列表
     */
    @PreAuthorize("@ss.hasPermi('modules:black:export')")
    @Log(title = "企业信用名单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CertificateBlack certificateBlack)
    {
        List<CertificateBlack> list = certificateBlackService.selectCertificateBlackList(certificateBlack);
        ExcelUtil<CertificateBlack> util = new ExcelUtil<CertificateBlack>(CertificateBlack.class);
        util.exportExcel(response, list, "企业信用名单数据");
    }

    /**
     * 获取企业信用名单详细信息
     */
    @PreAuthorize("@ss.hasPermi('modules:black:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") String ID)
    {
        return success(certificateBlackService.selectCertificateBlackByID(ID));
    }

    /**
     * 新增企业信用名单
     */
    @PreAuthorize("@ss.hasPermi('modules:black:add')")
    @Log(title = "企业信用名单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CertificateBlack certificateBlack)
    {
        return toAjax(certificateBlackService.insertCertificateBlack(certificateBlack));
    }

    /**
     * 修改企业信用名单
     */
    @PreAuthorize("@ss.hasPermi('modules:black:edit')")
    @Log(title = "企业信用名单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CertificateBlack certificateBlack)
    {
        return toAjax(certificateBlackService.updateCertificateBlack(certificateBlack));
    }

    /**
     * 删除企业信用名单
     */
    @PreAuthorize("@ss.hasPermi('modules:black:remove')")
    @Log(title = "企业信用名单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable String[] IDs)
    {
        return toAjax(certificateBlackService.deleteCertificateBlackByIDs(IDs));
    }
}
